package selef.xiafan.entity.order;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import selef.xiafan.entity.Customer;
import selef.xiafan.entity.system.Category;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Table(name = "t_order")
@Entity
@Data
@JsonIgnoreProperties({"handler", "hibernateLazyInitializer"})
public class Order implements Serializable {

    @Id
    @Column(name = "order_id")
    private String orderId;

    @DateTimeFormat(pattern = "yyyy-MM-dd hh-mm-ss")
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss",
            timezone = "GMT+8"
    )
    @Column(name = "create_time")
    private Date createTime;

    @DateTimeFormat(pattern = "yyyy-MM-dd hh-mm-ss")
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss",
            timezone = "GMT+8"
    )
    @Column(name = "reserve_date")
    private Date reserveDate;

    @Column(name = "description")
    private String descrip;

    private Integer status; // 服务状态【1已录入，2已提交，3进行中，4维修结束，5归还中, 6完成订单】

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss",
            timezone = "GMT+8"
    )
    private Date updateTime;

    @Column(name = "is_return")
    private Integer isReturn; // 0不需要，1需要

    @Column(name = "create_by")
    private String createBy; // 创建人

    @Column(name = "update_by")
    private String updateBy; // 修改人

    @Column(name = "total_price")
    private BigDecimal totalPrice;

    @Column(name = "address")
    private String address;

    /**
     * 订单选择了服务类型
     */
    @Transient
    private List<Category> category;

    /**
     * 是否已经评论 0，是 1，否
     */
    @Transient
    private Integer isComment;

    /**
     * 客户信息
     */
    @Transient
    private Customer customer;
}
